﻿using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SocketServer
{
    class DBConnection
    {
        public static MySqlConnection _conn;

        public static bool connect()
        {

            bool succeed = false;
            string h_connString = "server=localhost;user id=root; password=123321; port=3306; database=matter3d; pooling=false; charset=utf8";//根据实际修改

            try
            {
                if (_conn != null)
                    _conn.Close();

                _conn = new MySqlConnection(h_connString);

                _conn.Open();

                succeed = true;
            }

            catch (MySqlException ex)
            {
                Common.Log.Error(ex.Message);
            }

            return succeed;

        }

        public static void Close()
        {
            if (_conn != null)
                _conn.Close();
        }

    }
}
